import Vue from 'vue'
import Router from 'vue-router'
import layout from '@c/layout'
import home from './routes/home'
import articleList from './routes/article-list'
import articleDetail from './routes/article-detail'
import websocket from './routes/instant-message/websocket'
import comet from './routes/instant-message/comet'
import articleManage from './routes/manage/article'
import editor from './routes/manage/editor'
import manage from '@c/manage'

Vue.use(Router)
const VueRouterPush = Router.prototype.push
Router.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}

export default new Router({
  mode: 'history',
  routes: [
    home,
    {
      path: '/',
      name: 'layout',
      component: layout,
      children: [
        articleList, articleDetail, websocket, comet
      ]
    },
    {
      path: '/manage',
      name: 'manage',
      component: manage,
      children: [
        editor, articleManage
      ]
    }
  ]
})
